<!doctype html>
<script src="../../resources/testharness.js"></script>
<script src="../../resources/testharnessreport.js"></script>
<script src="../assert_selection.js"></script>
<script>
test(() => {
    assert_selection(
        '<div contenteditable>x|y</div>',
        'insertHTML <table><tr><td>1</td><td>2</td></tr></table>',
        [
            '<div contenteditable>',
                'x<table><tbody><tr><td>1</td><td>2|</td></tr></tbody></table>y',
            '</div>',
        ].join(''),
        'insert table into text');

    assert_selection(
        [
            '<div contenteditable>',
                '<table><tr><td><div>Item |1</div></td><td>Item 2</td></tr></table>',
            '</div>',
        ].join(''),
        'insertHTML <div>foo</div><div>bar</div>',
        [
            '<div contenteditable>',
                '<table><tbody><tr>',
                    '<td><div>Item foo</div><div>bar|1</div></td>',
                    '<td>Item 2</td>',
                '</tr></tbody></table>',
            '</div>',
        ].join(''),
        'insert DIV into table');
});
</script>
